package com.xhs.config;

import org.dromara.trans.service.impl.DictionaryTransService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @desc: easy-trans 字典翻译
 * @projectName: spring-boot-demo
 * @author: xhs
 * @date: 2024-07-14 014 22:31
 * @version: JDK 1.8
 */
@Slf4j
@Configuration
public class DictionaryConfig implements InitializingBean {

    @Resource
    private DictionaryTransService dictionaryTransService;

    @Override
    public void afterPropertiesSet() throws Exception {
        //将字典缓存刷新到翻译服务中
        Map<String,String> certificationStatus = new HashMap<>();
        certificationStatus.put("1","未认证");
        certificationStatus.put("2","认证中");
        certificationStatus.put("3","认证失败");
        certificationStatus.put("4","已认证");
        // 性别 0:女,1:男,2:保密
        Map<String,String> gender = new HashMap<>();
        gender.put("0","女");
        gender.put("1","男");
        gender.put("2","保密");
        // 任职状态 0:在职,1:离职
        Map<String,String> employmentStatus = new HashMap<>();
        employmentStatus.put("0","在职");
        employmentStatus.put("1","离职");
        // 账号状 0:正常,1:冻结
        Map<String,String> accountStatus = new HashMap<>();
        accountStatus.put("0","正常");
        accountStatus.put("1","冻结");
        log.info("\n -----------------easy-trans 字典翻译 -----------------");
        dictionaryTransService.refreshCache("certificationStatus",certificationStatus);
        dictionaryTransService.refreshCache("gender",gender);
        dictionaryTransService.refreshCache("employmentStatus",employmentStatus);
        dictionaryTransService.refreshCache("accountStatus",accountStatus);
    }
}
